<?php
class RadioButtonElement extends GroupElement {
	
	private $groupName;
	
	public function __construct($elementId, $text) {
		
		parent::__construct($elementId, $text);
	}
	
	public function setGroupName($groupName) {
		
		$this->groupName = $groupName;
	} 
	
	protected function renderElement() {
		
		$checked = '';
		
		if ($this->selected) {
			$checked = 'checked="checked"';
		}
	
		echo '<input type="radio" name="', $this->groupName, '" ', $this->formatAttributes(), ' ', $checked, '/>';
		echo '<label for="', $this->elementId, '">', $this->text, '</label>';
	}
	
}
?>